{% spaceless %}

{% set rows = [] %}

{% for food in foods %}
    {% set rows = rows|merge([{
        'id': food.publicId,
        'name': food.name,
    }]) %}
{% endfor %}

{% set response = {
    'success': true,
    'count': rows|length,
    'rows': rows
} %}

{{ response|json_encode|raw }}

{% endspaceless %}